package com.anysoft.fund;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.HorizontalScrollView;

import com.squareup.otto.Produce;

public class CHScrollView_Others extends HorizontalScrollView {

    int type;

    int lastL;
    int lastT;

    public CHScrollView_Others(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public CHScrollView_Others(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CHScrollView_Others(Context context) {
        super(context);
    }

    /**
     * 0-热门推荐 1-我的关注 2-货币基金 3-理财产品 4-股票基金 5-债券基金 6-指数基金 7-混合型 8-QDII 9-全部基金
     * 10-FOF
     */
    public void setType(int type) {
        this.type = type;
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        // 当前的CHSCrollView被触摸时，滑动其它
        lastL = l;
        lastT = t;
        switch (type) {
            case 2:
                BusProvider.getInstance().post(onScrollEvent_hb());
                break;
            case 3:
                BusProvider.getInstance().post(onScrollEvent_lc());
                break;
            case 4:
                BusProvider.getInstance().post(onScrollEvent_gp());
                break;
            case 5:
                BusProvider.getInstance().post(onScrollEvent_zq());
                break;
            case 6:
                BusProvider.getInstance().post(onScrollEvent_zs());
                break;
            case 7:
                BusProvider.getInstance().post(onScrollEvent_hh());
                break;
            case 8:
                BusProvider.getInstance().post(onScrollEvent_qdii());
                break;
            case 10:
                BusProvider.getInstance().post(onScrollEvent_fof());
                break;
            default:
                break;
        }

    }

    @Produce
    public OnScrollEvent_Hb onScrollEvent_hb() {
        return new OnScrollEvent_Hb(lastL, lastT);
    }

    @Produce
    public OnScrollEvent_Lc onScrollEvent_lc() {
        return new OnScrollEvent_Lc(lastL, lastT);
    }

    @Produce
    public OnScrollEvent_Gp onScrollEvent_gp() {
        return new OnScrollEvent_Gp(lastL, lastT);
    }

    @Produce
    public OnScrollEvent_Zq onScrollEvent_zq() {
        return new OnScrollEvent_Zq(lastL, lastT);
    }

    @Produce
    public OnScrollEvent_Zs onScrollEvent_zs() {
        return new OnScrollEvent_Zs(lastL, lastT);
    }

    @Produce
    public OnScrollEvent_Hh onScrollEvent_hh() {
        return new OnScrollEvent_Hh(lastL, lastT);
    }

    @Produce
    public OnScrollEvent_QDII onScrollEvent_qdii() {
        return new OnScrollEvent_QDII(lastL, lastT);
    }

    @Produce
    public OnScrollEvent_Fof onScrollEvent_fof() {
        return new OnScrollEvent_Fof(lastL, lastT);
    }
}
